app.register.controller("UserHeadimgCtrl", ["$rootScope", "$scope", "$location", "$timeout", "$window", "ToastMessage", "SecurityService", "Upload", function($rootScope, $scope, $location, $timeout, $window, ToastMessage, SecurityService, Upload) {
    $scope.ic = {},
    $scope.icLoaded = !1;
    var funs = {
        loadStatus: function() {
            SecurityService.status(function(data) {
                if (data && data.success) {
                    $scope.status = data.result;
                    var headImg = $rootScope.formatImgUrl($scope.status.credential.headimg);
                    headImg && $(".L_user_pic").attr("src", headImg)
                }
            })
        }
    };
    funs.loadStatus(),
    $scope.upload = function(file, type) {
        file && Upload.upload({
            url: app.res.url(8e3, "/pri/upload/uploadImg.jhtml"),
            data: {
                file: file,
                action: "headimg"
            }
        }).then(function(resp) {
            var ic = resp.data;
            ic && ic.result && ic.result.filepath && ($(".L_user_pic").bind("load", function() {
                $(".L_user_pic").removeClass("h-loading"),
                $(".L_user_pic").unbind("load")
            }),
            $(".L_user_pic").attr("src", $rootScope.formatImgUrl(ic.result.filepath)))
        }, function(resp) {}, function(evt) {
            $(".L_user_pic").attr("src", "../img/loading.gif").addClass("h-loading")
        })
    }
}
]);
